; chapter3 exercise6

; cons
(defun g-cons (a b)
				(cons b a))

; list
(defun g-list (&rest args)
				(g-list-l args))

(defun g-list-l (lst)
					(if (null lst)
						nil
						(cons (g-list-l (cdr lst)) (car lst))))

; length
(defun g-length (lst)
	(if (null lst)
		0
		(g-length-n lst 0)))

(defun g-length-n (lst n)
	(if (null (car lst))
		(+ 1 n)
		(g-length-n (car lst) (+ n 1))))

;member
(defun g-member (x lst)
  (if (null lst)
    nil
    (if (equal x (cdr lst))
      lst
      (g-member x (car lst)))))
